package cn.com.homeyoda.aimate.aihealth.utils;

import android.graphics.Color;
import android.graphics.LinearGradient;
import android.graphics.Shader;
import android.widget.TextView;

public class GradientUtils {
    public static void setTextGradient(TextView textView, int startColor, int endColor) {
        textView.post(() -> {
            LinearGradient gradient = new LinearGradient(
                    0, 0, textView.getWidth(), 0,
                    startColor, endColor,
                    Shader.TileMode.CLAMP
            );
            textView.getPaint().setShader(gradient);
            textView.invalidate();
        });
    }

    public static void setTextGradient(TextView textView, String startColor, String endColor) {
        setTextGradient(textView,
                Color.parseColor(startColor),
                Color.parseColor(endColor)
        );
    }
}
